package mysql.Base;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Scanner;

public class mysqlnsert {
    public static void main(String[] args) throws Exception {

        Scanner scanner = new Scanner(System.in);
        String name = scanner.next();
        int age=scanner.nextInt();
        String sex=scanner.next();

        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://master:3306/shujia",
                "root", "123456");
        Statement statement = connection.createStatement();

        String sql="insert into student(name,age,sex) values(\""+name+"\","+age+",\""+sex+"\")";
        int i = statement.executeUpdate(sql);
        System.out.println(i);
        if(i==1){
            System.out.println("注册成功");
        }else{
            System.out.println("注册失败");
        }
        statement.close();
        connection.close();
    }
}
